package com.tnl.app.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.biz.hunter.db.entity.SchDic;
import com.tnl.base.BaseDAO;

@Repository
public class SchDicDAO {
	
	private final static String SQL_GETALL = "select * from sch_dic where type = ? ";
	public List<SchDic> getAll(String type,int flag) {
		String sql = SQL_GETALL;
		if(flag == 1) {
			sql += " and flag = 1";
		} 
		sql += " order by convert(name using gbk) asc";
		return BaseDAO.queryForList(SchDic.class, sql, type);
	}
	
	private final static String SQL_GETNAME = "select * from sch_dic where type = ? and id = ?";
	public String getName(String id,String type) {
		SchDic dic = BaseDAO.queryForObject(SchDic.class, SQL_GETNAME, type, id);
		return dic == null ? "":dic.getName();
	}

}
